#ifndef __CACHEMANAGER_H__
#define __CACHEMANAGER_H__

// 单例模式，缓存管理类

#include "LRUCache.h"
#include <pthread.h>
#include <vector>

using namespace std;

class CacheManager
{
public:
    static CacheManager *getInstance();
    LRUCache& getKeyCache(int index);
   
    void periodicUpdateCaches();

private:
    CacheManager();
    ~CacheManager();
    static void init_r();
    static void destroy();
    // 初始化缓存
    void initCache(size_t threadNums,const string& keyPath);

private:
    static CacheManager* _pInstance;
    static pthread_once_t _once;
    vector<LRUCache> _keyCaches;
};

#endif